{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2020, 6, 20, 0, 0)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "today = datetime.date.today()\n",
    "time1 = datetime.datetime.strptime('2020-06-20', \"%Y-%m-%d\")\n",
    "time1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前时间戳为: 1594195495.462368\n"
     ]
    }
   ],
   "source": [
    "import time  # 引入time模块\n",
    "\n",
    "ticks = time.time()\n",
    "print (\"当前时间戳为:\", ticks)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本地时间为 : time.struct_time(tm_year=2020, tm_mon=7, tm_mday=8, tm_hour=16, tm_min=6, tm_sec=26, tm_wday=2, tm_yday=190, tm_isdst=0)\n"
     ]
    }
   ],
   "source": [
    "localtime = time.localtime(time.time())\n",
    "print (\"本地时间为 :\", localtime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1: time.struct_time(tm_year=2020, tm_mon=7, tm_mday=8, tm_hour=16, tm_min=24, tm_sec=7, tm_wday=2, tm_yday=190, tm_isdst=0)\n",
      "2020-07-08 16:24:07\n",
      "1459175064.0\n"
     ]
    }
   ],
   "source": [
    "t1 = time.localtime()\n",
    "print ('1:',t1)\n",
    "# 格式化成2016-03-20 11:45:39形式\n",
    "print (time.strftime(\"%Y-%m-%d %H:%M:%S\", t1))\n",
    "\n",
    "# 将格式字符串转换为时间戳\n",
    "a = \"Sat Mar 28 22:24:24 2016\"\n",
    "print (time.mktime(time.strptime(a,\"%a %b %d %H:%M:%S %Y\")))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020-07-08 17:09:34\n"
     ]
    }
   ],
   "source": [
    "t1 = time.localtime()\n",
    "print (time.strftime(\"%Y-%m-%d %H:%M:%S\", t1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/07/08 17:08:05\n"
     ]
    }
   ],
   "source": [
    "print (time.strftime(\"%Y/%m/%d %H:%M:%S\", t1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2011, tm_mon=5, tm_mday=5, tm_hour=16, tm_min=37, tm_sec=6, tm_wday=3, tm_yday=125, tm_isdst=-1)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strptime('2011-05-05 16:37:06', '%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2011, tm_mon=5, tm_mday=5, tm_hour=16, tm_min=37, tm_sec=6, tm_wday=3, tm_yday=125, tm_isdst=-1)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strptime('2011/05/05 16:37:06', '%Y/%m/%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "abs(-40) :  40\n",
      "abs(100.10) :  100.1\n"
     ]
    }
   ],
   "source": [
    "print (\"abs(-40) : \", abs(-40))\n",
    "print (\"abs(100.10) : \", abs(100.10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3]\n",
    "help(a.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8.0"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import math\n",
    "math.pow(2, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
